home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-10-30 | 3.7 KB | 181 lines | [TEXT/CWIE] |
- { ModalStuff.p -- Modal dialog }
- { Created 10/30/98 1:06 PM by AppMaker }
-
- Unit ModalStuff;
- Interface
-
- Uses
- Types,
- Quickdraw,
- Controls,
- Dialogs,
- Events,
- Lists,
- Menus,
- TextEdit,
- DModalStuffData,
- AMDialog;
-
- type
- CModalStuff = object (AMDialog)
-
- {data members}
- mData: DModalStuffData;
-
- mOKHandle: ControlHandle;
- mToolsHandle: ControlHandle;
- mPopupsHandle: ControlHandle;
- mFromValuesList2Handle: ControlHandle;
- mFromMenuHandle: ControlHandle;
- mListsHandle: ControlHandle;
- mTextListHandle: ControlHandle;
-
- {methods - public}
- Procedure ConnectToData (inData: AMSignaler); Override;
-
- {methods - internal}
- Procedure FinishMake; Override;
- Procedure DoItem (inItemHit: SInt16); Override;
- Procedure DataChanged (inDataID: longint); Override;
-
- end;
-
- {----------}
- Function NewModalStuff: CModalStuff;
-
- {----------}
- Function GetModalStuff (ioData: DModalStuffData): Boolean;
-
- {----------}
- Implementation
-
- Uses
- ResourceDefs,
- ControlUtils,
- Miscellany;
-
- const
- kOKButton = 1;
- kToolsPalette = 2;
- kPopupsBox = 3;
- kFromValuesList2Popup = 4;
- kFromMenuPopup = 5;
- kListsBox = 6;
- kTextListList = 7;
-
- { Procedure BuildTextListList (inControl: ControlHandle); }
-
- {----------}
- Procedure BuildTextListList (
- inControl: ControlHandle);
- var
- list: ListHandle;
- begin
- list := GetListHandle (inControl);
- AddToList ("One", list);
- AddToList ("Two", list);
- AddToList ("Three", list);
- AddToList ("Infinity", list);
-
- end; {BuildTextListList}
-
- {----------}
- Function NewModalStuff: CModalStuff;
- var
- dialog: CModalStuff;
- begin
- dialog := nil;
- New (dialog);
-
- if dialog <> nil then begin
- dialog.Initialize;
- end;
- NewModalStuff := dialog;
- end;
-
- {----------}
- Function GetModalStuff (
- ioData: DModalStuffData): Boolean;
- Var
- result: Boolean;
- dialog: CModalStuff;
- begin
- result := false;
- dialog := NewModalStuff;
-
- result := dialog.RunModal (DLOG_ModalStuff, ioData);
-
- dialog.Free;
- Dispose (dialog);
-
- GetModalStuff := result;
- end;
-
- {----------}
- Procedure CModalStuff.FinishMake;
- var
- errCode: OSErr;
- begin
- mOKHandle := GetControlItem (kOKButton);
- SetDefaultState (mOKHandle, true);
- errCode := SetDialogDefaultItem (mDialog, kOKButton);
- mToolsHandle := GetControlItem (kToolsPalette);
- mPopupsHandle := GetControlItem (kPopupsBox);
- mFromValuesList2Handle := GetControlItem (kFromValuesList2Popup);
- mFromMenuHandle := GetControlItem (kFromMenuPopup);
- mListsHandle := GetControlItem (kListsBox);
- mTextListHandle := GetControlItem (kTextListList);
- end;
-
- {----------}
- Procedure CModalStuff.ConnectToData (
- inData: AMSignaler); Override;
- begin
- inherited ConnectToData (inData);
- mData := DModalStuffData (inData);
-
- SetControlValue (mToolsHandle, mData.GetTools2);
- SetControlValue (mFromValuesList2Handle, mData.GetFromValuesList3);
- SetControlValue (mFromMenuHandle, mData.GetFromMenu2);
- BuildTextListList (mTextListHandle);
- SetListBoxChoice (mTextListHandle, mData.GetTextList2);
- end;
-
- {----------}
- Procedure CModalStuff.DoItem (
- inItemHit: SInt16);
- begin
- case inItemHit of
- kOKButton:
- SetResult (true);
- kToolsPalette:
- mData.SetTools2 (GetControlValue (mToolsHandle));
- kFromValuesList2Popup: begin
- mData.SetFromValuesList3 (GetControlValue (mFromValuesList2Handle));
- end;
- kFromMenuPopup: begin
- mData.SetFromMenu2 (GetControlValue (mFromMenuHandle));
- end;
- kTextListList:
- mData.SetTextList2 (GetListBoxChoice (mTextListHandle));
-
- end; {switch}
- end;
-
- {----------}
- Procedure CModalStuff.DataChanged (
- inDataID: longint); Override;
- begin
- if inDataID = idTools2 then begin
- SetControlValue (mToolsHandle, mData.GetTools2);
- end;
- if inDataID = idFromValuesList3 then begin
- SetControlValue (mFromValuesList2Handle, mData.GetFromValuesList3);
- end;
- if inDataID = idFromMenu2 then begin
- SetControlValue (mFromMenuHandle, mData.GetFromMenu2);
- end;
- end;
-
- End.
-